home *** CD-ROM | disk | FTP | other *** search
- #include <genstub.c>
-
- LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- static char szSaveEnvVar[128];
- switch (uMsg)
- {
- case WM_CREATE:
- GetEnvironmentVariable( "Test", szSaveEnvVar, MAX_PATH + 1 );
- return DefWindowProc( hWnd, uMsg, wParam, lParam );
- case WM_COMMAND:
- switch ( LOWORD( wParam ) )
- {
- case IDM_TEST: // Sets Env Var "Test" to token on command line.
- {
- char szMessage[2*( MAX_PATH + 1 )];
- char szCommandLine[256];
- LPTSTR lpTemp = NULL;
-
- // Read command line into local buffer.
- lstrcpy( szCommandLine, GetCommandLine() );
-
- // Search for extra input after program name.
- lpTemp = strstr( szCommandLine, " " );
- if (lpTemp)
- lpTemp = strtok(lpTemp, " ");
-
- // "Test" is removed from environment if there is no token.
- SetEnvironmentVariable( "Test", lpTemp );
- // Show change in message box.
- wsprintf( szMessage, "'Test' was [%s], New Value=[%s]",
- szSaveEnvVar, lpTemp );
- MessageBox( hWnd, szMessage,
- "Changing Environment Variable", MB_OK );
- }
- break;
- case IDM_EXIT:
- DestroyWindow( hWnd );
- break;
- }
- break;
- case WM_DESTROY:
- PostQuitMessage( 0 );
- break;
- default:
- return (DefWindowProc(hWnd, uMsg, wParam, lParam));
- }
- return (NULL);
- }